package org.dtrd.modules.device.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dtrd.modules.device.entity.po.DtrdEntRdXtyPushContent;
import org.dtrd.modules.device.mapper.DtrdEntRdXtyPushContentMapper;
import org.dtrd.modules.device.service.IDtrdEntRdXtyPushContentService;
import org.springframework.stereotype.Service;

/**
 * @author 萧
 * @date 2021-09-01 00:02:01
 **/
@Service
@DS("multi-datasource1")
public class DtrdEntRdXtyPushContentServiceImpl extends ServiceImpl<DtrdEntRdXtyPushContentMapper, DtrdEntRdXtyPushContent> implements IDtrdEntRdXtyPushContentService {

    @Override
    public void savePushRecord(String msgId, String msgType, String pushContent) {
        DtrdEntRdXtyPushContent content = new DtrdEntRdXtyPushContent().init();
        content.setMsgId(msgId);
        content.setMsgType(msgType);
        content.setContent(pushContent);
        save(content);
    }

    @Override
    public DtrdEntRdXtyPushContent getRecordByMsgId(String msgId) {
        LambdaQueryWrapper<DtrdEntRdXtyPushContent> query = new LambdaQueryWrapper<>();
        query.eq(DtrdEntRdXtyPushContent::getIsDel, 0).eq(DtrdEntRdXtyPushContent::getMsgId, msgId);
        return getBaseMapper().selectOne(query);
    }
}
